package com.uam.core.lk.utils;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SDKResponseBody<T> {

    private Integer status;
    private String message;
    private T result;

    public enum StatusEnum {
        // @formatter:off
        SUCCESS(0, "请求成功"),
        INTERNAL_SERVER_ERROR(1, "服务器内部错误"),
		PARAM_ERROR(2, "请求参数非法"),
		PARAM_IS_NULL(3, "缺少必要参数"),
		AUTHENTICATE_FAIL(4, "认证失败"),
		INTERFACE_PERMISSION_DENY(5, "没有该接口访问权限"),
		REQUEST_METHOD_NOT_SUPPORT(6, "请求方式不支持"),
		UNKNOWN_ERROR(7, "其他未知错误"),
		REQUEST_PATH_ERROR(8, "请求路径错误"),
		REQUEST_TIMEOUT(9, "请求超时"),
//		AK_UNAVAILABLE(101, "AK获取不到"),
//		PASSWORD_NOT_PARSED(102, "password参数不存在。该错误码代表服务器没有解析到password"),
//        TOKEN_ILLGAL(103, "鉴权失败，token非法"),
//        TOKEN_EXPIRE(104, "鉴权失败，token超过有效期"),
//        CLIENT_ID_AUTHENTICATE_FAIL(105, "clientId鉴权失败"),
//        TOKEN_NOT_PARSED(106, "鉴权失败，未检测到token信息"),
//        SIGN_NOT_EXISTS(107, "签名不存在"),
//        SIGN_VERIFY_FAILED(108, "签名校验失败"),
//		------ add by zhangxj at 20200528 as 统一定义状态码 ---start
		GATEWAY_TOKEN_ILLGAL(103, "鉴权失败，access_token非法"),
		GATEWAY_TOKEN_EXPIRE(104, "鉴权失败，access_token超过有效期"),
		GATEWAY_CLIENT_ID_AUTHENTICATE_FAIL(105, "clientId鉴权失败"),
//		Android或IOS的sdk中的106代表  鉴权失败，未检测到access_token信息；  web端或者js请求中106代表ak不存在
		GATEWAY_TOKEN_NOT_PARSED(106, "AK参数不存在"),
		GATEWAY_SIGN_NOT_EXISTS(107, "签名参数不存在"),
		GATEWAY_SIGN_VERIFY_FAILED(108, "数字签名未通过验证"),
		GATEWAY_TOKEN_VERIFY_FAILED(109, "鉴权失败，access_token校验失败"),
		GATEWAY_SIGN_VERIFY_REPEAT_FAILED(110, "签名值重复使用"),
		GATEWAY_AK_VERIFY_FAILED(122, "AK值不正确"),
		GATEWAY_AK_STATUS_IS_NULL(123, "AK状态值不能为空"),
		GATEWAY_AK_TYPE_IS_NULL(124, "AK的类型不能为空"),
		GATEWAY_AK_TYPE_OUT_OF_RANGE(125, "AK的类型值超出范围"),
		GATEWAY_AK_STATUS_DISABLE(126, "AK状态值不可用"),
		GATEWAY_CLIENT_IP_IS_NULL(127, "IP白名单出错，无法获取客户端IP"),
		GATEWAY_CLIENT_IP_NO_ACCESS(128, "IP白名单出错，发送请求的服务器IP不在IP白名单内"),
		GATEWAY_CLIENT_IP_OUT_OF_RANGE(129, "IP访问超限"),
		GATEWAY_CLIENT_DOMAIN_NAME_IS_NULL(130, "域名白名单出错，无法获取客户端域名"),
		GATEWAY_CLIENT_DOMAIN_NAME_NO_ACCESS(131, "域名白名单出错，发送请求的域名不在域名白名单内"),


		GATEWAY_AK_INTERFACE_PERMISSION_DENY(141, "开发者没有权限使用相应的服务"),
		GATEWAY_AK_DAILY_QUERY_OVER_LIMIT(142, "访问已超出日访问量"),
		GATEWAY_AK_CKQPS_HAS_EXCEEDED_THE_LIMIT(143, "某个AK使用某个服务接口QPS超出限制"),


		AUTH_TOKEN_GRANT_TYPE_IS_NULL(300, "获取access_token时grant_type不能为空"),
		AUTH_TOKEN_GRANT_TYPE_IS_PASSWORD(301, "获取access_token时grant_type值不正确"),
		AUTH_TOKEN_TIMESTAMP_IS_NULL(302, "获取access_token时timestamp不能为空"),
		AUTH_TOKEN_TIMESTAMP_OUT_OF_RANGE(303, "获取access_token时timestamp值超出范围"),
		AUTH_TOKEN_NONCE_IS_NULL(304, "获取access_token时nonce不能为空"),
		AUTH_TOKEN_USERNAME_IS_NULL(305, "获取access_token时username不能为空"),
		AUTH_TOKEN_PASSWORD_IS_NULL(306, "获取access_token时password不能为空"),
		AUTH_TOKEN_PASSWORD_VERIFY_FAILED(307, "获取access_token时password值校验失败"),
		AUTH_TOKEN_PASSWORD_REPEAT_FAILED(308, "获取access_token时请求重复"),
		AUTH_TOKEN_AK_IS_NULL(309, "获取access_token时AK不能为空"),
		AUTH_TOKEN_AK_FAILED(310, "获取access_token时AK查询不到数据"),
		AUTH_TOKEN_AK_VERIFY_FAILED(311, "获取access_token时AK凭证校验失败"),
		AUTH_TOKEN_TOKEN_IS_NULL(312, "无法获取access_token值"),


//		------ add by zhangxj at 20200528 as 统一定义状态码 ---end

        APP_NOT_EXISTS(200, "APP不存在，根据请求的 username(AK)，找不到对应的 APP"),
        APP_DISABLED_BY_SELF(201, "APP使用的服务被用户自己禁用，请在控制台解禁"),
        APP_DELETED_CAUSE_BY_MALICE(202, "恶意 APP被管理员删除"),
        APP_NOT_MATCH_AK(203, "APP类型与 username(AK)类型不符合"),
        APP_IP_VALIDATION_FAIL(204, "AK IP校验失败，WEB API、JS API专属错误码"),
        APP_SN_VALIDATION_FAIL(205, "AK SN校验失败，WEB API专属错误码"),
        PASSWORD_VALIDATION_FAIL(206, "password校验失败。服务器能解析到 password，但和数据库中不一致"),
        USER_NOT_EXISTS(207, "用户不存在"),
		USER_DISABLED(208, "用户封禁"),
        SERVICE_DISABLED_BY_PLATFORM(209, "服务被开放平台禁用"),
		REQUEST_PARAM_FORMAT_ERROR(210, "请求消息体格式错误"),

//        PERMANENT_LIMIT_EXCEED(301, "永久配额超限"),
//        DAY_LIMIT_EXCEED(302, "天配额超限"),
//        CURRENT_EXCEED_CONCURRENT_LIMIT(303, "当前并发量已经超过约定并发配额"),
//        CURRENT_EXCEED_CONCURRENT_LIMIT_AND_TOTAL_EXCEED(304, "当前并发量已经超过约定并发配额，并且服务总并发量也已经超过设定的总并发配额"),
//        REQUEST_TIMEOUT(310, "请求超时")
		;
        // @formatter:onl

        private Integer status;
        private String message;

        private StatusEnum(Integer code, String message) {
            this.status = code;
            this.message = message;
        }

        public Integer getStatus() {
            return this.status;
        }

        public String getMessage() {
            return this.message;
        }
    }
}
